package com.cnhis.cloudhealth.clidoctorweb.medicine;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.medicine.service.IMedicine;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import java.util.HashMap;

@Path("medicine")
@Component
public class MedicineRest
{
    @Reference
    private IMedicine medicine;
    
    /* ScriptId(744) */
    /* Description(药品：门诊按规格下医嘱) */
    /**
     * 
     * @param BBY01 收费项目id
     * @param productId
     * @param programId
     * @param paramNo 9999,9999,63)
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("patientcasehistory")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryMedicine(@FormParam("BBY01") int BBY01,@FormParam("bck01") int bck01,@FormParam("yiyuanId") int yiyuanId)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBY01", BBY01);
        map.put("bck01", bck01);
        map.put("yiyuanId", yiyuanId);
        map.put("productid", 9999);
        map.put("programid", 9999);
        map.put("paramno", 63);
        return medicine.queryMedicine(map, 1, 1);
    }
    
    /* ScriptId(1547) */
    /* Description(判断此病人是否对此药物过敏) */
    /**
     * 
     * @param VAA01
     * @param BBX01
     * @param BBX05
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("patientallergymedicine")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo patientAllergyMedicine(@FormParam("VAA01") int VAA01, @FormParam("BBX01") int BBX01,
        @FormParam("BBX05") String BBX05)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("VAA01", VAA01);
        map.put("BBX01", BBX01);
        map.put("BBX05", BBX05);
        return medicine.patientAllergyMedicine(map);
    }
    
    /* ScriptId(7282) */
    /* Description(药物过敏记录) */
    @SuppressWarnings("unchecked")
    @POST
    @Path("medicineallergy")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo medicineAllergy(@FormParam("aDate") String aDate, @FormParam("vaa01") int vaa01,
        @FormParam("bbx01") int bbx01, @FormParam("van09") int van09, @FormParam("currPage") int currPage,
        @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("aDate", aDate);
        map.put("vaa01", vaa01);
        map.put("van09", van09);
        return medicine.medicineAllergy(map, (currPage - 1) * pageSize, pageSize);
    }
    
    /* ScriptId(7313) */
    /* Description(下达药品医嘱，获取默认用法用量) */
    @SuppressWarnings("unchecked")
    @GET
    @Path("medicinedefaultdosage")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo medicineDefaultDosage(@QueryParam("BBX01") int BBX01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBX01", BBX01);
        return medicine.medicineDefaultDosage(map);
        
    }
    
    /* ScriptId(7327) */
    /* Description(提取诊疗频次、给药途径对应执行时间方案) */
    /**
     * 
     * @param BDI01 诊疗频次
     * @param BBX01 途径id
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("executetimecase")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo executeTimeCase(@FormParam("BDI01") String BDI01, @FormParam("BBX01") int BBX01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BDI01", BDI01);
        map.put("BBX01", BBX01);
        return medicine.executeTimeCase(map);
    }
    
    /* ScriptId(725) */
    /* Description(树形：按药品规格 检索品种分类对应的明细项目) */
    /**
     * 
     * @param lACF01
     * @param lBDO01 医疗项目分类id
     * @param lSql 搜索
     * @param abc02 病人费别
     * @param bdp02 病人类型
     * @param lBDA01 医疗项目类别
     * @param lBCK01 部门id
     * @param lDate 日期
     * @param BCKyf
     * @param vaf58 给药性质
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("queryitemdetail")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryItemDetail(@FormParam("lACF01") int lACF01, @FormParam("lBDO01") int lBDO01,
        @FormParam("lSql") String lSql, @FormParam("abc02") String abc02, @FormParam("bdp02") String bdp02,
        @FormParam("lBDA01") String lBDA01, @FormParam("lBCK01") int lBCK01, @FormParam("lDate") String lDate,
        @FormParam("BCKyf") int BCKyf, @FormParam("vaf58") int vaf58, @FormParam("currPage") int currPage,
        @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lACF01", lACF01);
        map.put("lBDO01", lBDO01);
        map.put("lSql", lSql == null || "".equals(lSql) ? "%" : lSql + "%");
        map.put("abc02", abc02);
        map.put("bdp02", bdp02);
        map.put("lBDA01", lBDA01);
        map.put("lBCK01", lBCK01);
        map.put("lDate", lDate);
        map.put("BCKyf", BCKyf);
        map.put("vaf58", vaf58);
        return medicine.queryItemDetail(map, currPage, pageSize);
    }
    
    /* ScriptId(6431) */
    /* Description(提取部门排班中默认药房) */
    /**
     * 
     * @param lBBY01 收费项目id
     * @param lACF01 1
     * @param lBCK01 员工id
     * @param aParamno
     * @param BDN01 收费项目类型
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("getdefaultpharmacy")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getDefaultPharmacy(@FormParam("lBBY01") int lBBY01, @FormParam("lACF01") int lACF01,
        @FormParam("lBCK01") Long lBCK01, @FormParam("aParamno") String aParamno, @FormParam("BDN01") String BDN01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lBBY01", lBBY01);
        map.put("lACF01", lACF01);
        map.put("lBCK01", lBCK01);
        map.put("aParamno", aParamno);
        map.put("BDN01", BDN01);
        return medicine.getDefaultPharmacy(map);
    }
    
    /* ScriptId(1676) */
    /* Description(获取药品当前库存数量) */
    /**
     * 
     * @param lBCK01 科室id
     * @param lACF01
     * @param lBBY01 收费项目
     * @param aParamno
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("getdrugcount")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getDrugCount(@FormParam("lBCK01") int lBCK01, @FormParam("lACF01") int lACF01,
        @FormParam("lBBY01") int lBBY01, @FormParam("aParamno") String aParamno)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lBCK01", lBCK01);
        map.put("lACF01", lACF01);
        map.put("lBBY01", lBBY01);
        map.put("aParamno", aParamno);
        return medicine.getDrugCount(map);
    }
    
    /* ScriptId(7378) */
    /* Description(判断中药方剂中是否已经有失效药品) */
    /**
     * 
     * @param BBX01A 诊疗方案id
     * @param adate 日期
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("disableddrug")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo disabledDrug(@FormParam("lBBX01A") int lBBX01A, @FormParam("adate") String adate)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lBBX01A", lBBX01A);
        map.put("adate", adate);
        return medicine.disabledDrug(map);
    }
}
